#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 85;
const int MX = 1000000000;
int n, m;
int a[N][N];
__int128 dp[N][N];
void out(__int128 x) {
  if (x / 10) out(x / 10);
  cout << int(x % 10);
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  rep(i, 1, n) rep(j, 1, m) cin >> a[i][j];
  __int128 ans = 0;
  rep(i, 1, n) {
    rep(j, 1, m) dp[j][j] = a[i][j];
    rep(len, 2, m) {
      rep(l, 1, m + 1 - len) {
        int r = l + len - 1;
        dp[l][r] = max(a[i][l] + 2 * dp[l + 1][r], a[i][r] + 2 * dp[l][r - 1]);
      }
    }
    ans += 2 * dp[1][m];
  }
  out(ans);
  return 0;
}